package edu.unf.cen6940.service;

import edu.unf.cen6940.domain.Facultyresearchtostudent;
import edu.unf.cen6940.domain.Student;
import edu.unf.cen6940.domain.Thesis;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/rms_test-security-context.xml",
		"file:./resources/rms_test-service-context.xml",
		"file:./resources/rms_test-dao-context.xml",
		"file:./resources/rms_test-web-context.xml" })
@Transactional
public class StudentServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected StudentService service;

	/**
	 * Instantiates a new StudentServiceTest.
	 *
	 */
	public StudentServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 * Return all Student entity
	 * 
	 */
	@Test
	public void findAllStudents() {
		// TODO: JUnit - Populate test inputs for operation: findAllStudents 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<Student> response = null;
		response = service.findAllStudents(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllStudents
	}

	/**
	 * Operation Unit Test
	 * Load an existing Student entity
	 * 
	 */
	@Test
	public void loadStudents() {
		Set<Student> response = null;
		response = service.loadStudents();
		// TODO: JUnit - Add assertions to test outputs of operation: loadStudents
	}

	/**
	 * Operation Unit Test
	 * Save an existing Thesis entity
	 * 
	 */
	@Test
	public void saveStudentThesises() {
		// TODO: JUnit - Populate test inputs for operation: saveStudentThesises 
		Integer studentId = 0;
		Thesis related_thesises = new edu.unf.cen6940.domain.Thesis();
		Student response = null;
		response = service.saveStudentThesises(studentId, related_thesises);
		// TODO: JUnit - Add assertions to test outputs of operation: saveStudentThesises
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Thesis entity
	 * 
	 */
	@Test
	public void deleteStudentThesises() {
		// TODO: JUnit - Populate test inputs for operation: deleteStudentThesises 
		Integer student_studentId = 0;
		Integer related_thesises_thesisId = 0;
		Student response = null;
		response = service.deleteStudentThesises(student_studentId, related_thesises_thesisId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteStudentThesises
	}

	/**
	 * Operation Unit Test
	 * Save an existing Facultyresearchtostudent entity
	 * 
	 */
	@Test
	public void saveStudentFacultyresearchtostudents() {
		// TODO: JUnit - Populate test inputs for operation: saveStudentFacultyresearchtostudents 
		Integer studentId_1 = 0;
		Facultyresearchtostudent related_facultyresearchtostudents = new edu.unf.cen6940.domain.Facultyresearchtostudent();
		Student response = null;
		response = service.saveStudentFacultyresearchtostudents(studentId_1, related_facultyresearchtostudents);
		// TODO: JUnit - Add assertions to test outputs of operation: saveStudentFacultyresearchtostudents
	}

	/**
	 * Operation Unit Test
	 * Return a count of all Student entity
	 * 
	 */
	@Test
	public void countStudents() {
		Integer response = null;
		response = service.countStudents();
		// TODO: JUnit - Add assertions to test outputs of operation: countStudents
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Student entity
	 * 
	 */
	@Test
	public void deleteStudent() {
		// TODO: JUnit - Populate test inputs for operation: deleteStudent 
		Student student = new edu.unf.cen6940.domain.Student();
		service.deleteStudent(student);
	}

	/**
	 * Operation Unit Test
	 * Save an existing Student entity
	 * 
	 */
	@Test
	public void saveStudent() {
		// TODO: JUnit - Populate test inputs for operation: saveStudent 
		Student student_1 = new edu.unf.cen6940.domain.Student();
		service.saveStudent(student_1);
	}

	/**
	 * Operation Unit Test
	 * Delete an existing Facultyresearchtostudent entity
	 * 
	 */
	@Test
	public void deleteStudentFacultyresearchtostudents() {
		// TODO: JUnit - Populate test inputs for operation: deleteStudentFacultyresearchtostudents 
		Integer student_studentId_1 = 0;
		Integer related_facultyresearchtostudents_facultyResearchId = 0;
		Integer related_facultyresearchtostudents_studentId = 0;
		Integer related_facultyresearchtostudents_facultyId = 0;
		Student response = null;
		response = service.deleteStudentFacultyresearchtostudents(student_studentId_1, related_facultyresearchtostudents_facultyResearchId, related_facultyresearchtostudents_studentId, related_facultyresearchtostudents_facultyId);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteStudentFacultyresearchtostudents
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findStudentByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findStudentByPrimaryKey 
		Integer studentId_2 = 0;
		Student response = null;
		response = service.findStudentByPrimaryKey(studentId_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findStudentByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
